/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sais.eswn.card.cardlabel;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.sais.eswn.core.Player;

/**
 *
 * @author Romulus
 */
  public class UniLabel extends CardLabel {

    int region = -1;

    /**
     * Used in deck editor.
     * @param parent
     * @param cardno
     * @param isWatcher
     */
    public UniLabel(ICardLabelCallback parent, String cardno, boolean isWatcher) {
      super(parent, cardno, Player.ICH, isWatcher);
      addMouseListener(stdml);
    }

    /**
     * Used in game.
     * @param parent
     * @param cardno
     * @param region
     * @param isWatcher
     */
    public UniLabel(ICardLabelCallback parent, String cardno, int region, boolean isWatcher) {
      this(parent, cardno, isWatcher);
      this.region = region;
      setPopupMenu();
    }

    public SpellLabel toSpell(int direction) {
      return new SpellLabel(parent, Player.ICH, cardno, direction,isWatcher);
    }

    public EventLabel toEvent() {
      return new EventLabel(parent, Player.ICH, cardno,isWatcher);
    }

    public void setRegion(int region) {
      this.region = region;
    }

    public int getRegion() {
      return region;
    }

    public void setPopupMenu() {
      if (cardno == null) {
        return;
      }
      if (mMenu != null) {
        remove(mMenu);
      }
      mMenu = new JPopupMenu();
      JMenuItem title = new JMenuItem(getInfo().name);
      mMenu.add(title);
      mMenu.addSeparator();
      if (isWatcher) {
        add(mMenu);
        return;
      }
    }

    class UniCommandListener implements ActionListener {

      int targetregion;

      UniCommandListener(int targetregion) {
        this.targetregion = targetregion;
      }

      @Override
      public void actionPerformed(ActionEvent e) {
        //parent.UniMove(self, targetregion);
      }
    }
  }